package com.gamewithpurpose.dbinterface;

import java.util.List;

import org.junit.Test;

import com.gamewithpurpose.dbinterface.AnswerDAO;
import com.gamewithpurpose.dbinterface.POJO.Answer;


public class AnswerDAOTest extends UnitCommon {
	@Test
	public void testAdd() {
		AnswerDAO.deleteAll();
		AnswerDAO.addAnswer(0, 0, "this is a test");
		List<Answer> res = AnswerDAO.list();
		
		assertEquals(res.size(), 1);
		AnswerDAO.deleteAll();
		res = AnswerDAO.list();
		assertEquals(res.size(), 0);
	}
	
	@Test 
	public void testDelete() {
		AnswerDAO.deleteAll();
		AnswerDAO.addAnswer(0, 0, "this is a test");
		List<Answer> res = AnswerDAO.list();
		assertEquals(res.size(), 1);
		
		AnswerDAO.delete(res.get(0).getId());
		res = AnswerDAO.list();
		assertEquals(res.size(), 0);
	}
}
